<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@include file="/WEB-INF/view/common/common.jsp" %>

<!DOCTYPE html>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>求职者-查询</title>
		<link rel="stylesheet" href="<%=request.getContextPath() %>/vendor/bootstrap-3.3.7-dist/css/bootstrap.min.css"/>
	</head>
	<body>
		<h2 class="text-center">我的资料</h2>
		<hr>
		
		<div class="container">
			<form class="form-horizontal" data-validator-option="{timely:2}">
			<a href="${ctx }/position_listAll.action"><b>招聘首页</b></a>
			&nbsp;
			<a href="${ctx }/talentInfoUpdateUI.action"><b>修改资料</b></a>
				<div class="form-group">
				    <label for="code" class="col-sm-2 control-label">账号：</label>
				    <div class="col-sm-10">
				      <input type="text" class="form-control" maxLength="10" name="talent.code" value="${talent.code }" onblur="checkUsername(this.value)" data-rule="required; length(2~10)" readonly>
				    </div>
				  </div>
				  <div class="form-group">
			     <label for="password" class="col-sm-2 control-label">密码：</label>
			     <div class="col-sm-10">
			      <input type="password" class="form-control" name="talent.password" value="${talent.password }" readonly>
			    	</div>
			   	 	</div>
				  <div class="form-group">
				    <label for="name" class="col-sm-2 control-label">姓名：</label>
				    <div class="col-sm-10">
				      <input type="text" class="form-control" maxLength="10" name="talent.name" value="${talent.name }" data-rule="required; length(2~10)" readonly>
				    </div>
				  </div>
				  <div class="form-group">
				    <label for="phone" class="col-sm-2 control-label">手机号码：</label>
				    <div class="col-sm-10" style="float: left;">
				      <input type="text" class="form-control" maxLength="11" name="talent.phone" value="${talent.phone }" data-rule="required; tel|mobile" readonly>
				    </div>
				  </div>
				  <div class="form-group">
				    <label for="email" class="col-sm-2 control-label">电子邮箱：</label>
				    <div class="col-sm-10">
				      <input type="text" class="form-control" maxLength="50" name="talent.email" value="${talent.email }" data-rule="required; email; length(~50)" readonly>
				    </div>
				  </div>
				  <div class="form-group">
				    <label for="age" class="col-sm-2 control-label">年龄：</label>
				    <div class="col-sm-10">
						<input type="text" class="form-control" name="talent.age" value="${talent.age}" readonly>
				    </div>
				  </div>
				  <div class="form-group">
				    <label for="gender" class="col-sm-2 control-label">性别：</label>
				    <div class="col-sm-10">
				     	<label class="radio-inline">
						  <input type="radio" name="talent.gender" value="1" checked="checked"> 男
						</label>
						<label class="radio-inline">
						  <input type="radio" name="talent.gender" value="2" > 女
						</label>
				    </div>
				  </div>
				  <div class="form-group">
				    <label for="interestPositions" class="col-sm-2 control-label">爱好：</label>
				    <div class="col-sm-10">
				      <input type="text" class="form-control" maxLength="10" name="talent.interestPositions" value="${talent.interestPositions }" data-rule="required; length(~10)" readonly>
				    </div>
				  </div>
			</form>
		</div>
		<script src="<%=request.getContextPath()%>/vendor/jquery.min.js"></script>
	    <script src="<%=request.getContextPath()%>/vendor/layer/layer.js"></script>
	    <script src="<%=request.getContextPath()%>/vendor/nice-validate-1.1.2/jquery.validator.min.js?local=zh-CN"></script>
		<script>
			function checkUsername(username) {
					if (username == '') {
						return;
					}
					// 1、找一个人帮我做事情
					var xmlhttp;
					if (window.XMLHttpRequest) {
					  // code for IE7+, Firefox, Chrome, Opera, Safari
					  xmlhttp=new XMLHttpRequest();
				    } else {
				      // code for IE6, IE5
					  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
					}
					
					// 2、告诉他做什么？去哪里做？
					xmlhttp.open("GET", "<%=request.getContextPath()%>/TalentServlet?command=checkcode&code=" + username + '&time=' + new Date().getTime(), true);
					
					// 3、派出去
					xmlhttp.send();
					
					// 4、监听并得到这个人反馈的结果
					
					xmlhttp.onreadystatechange = function() {
						if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
							var result = xmlhttp.responseText;
							
							if ('true' == result) {
								layer.msg('用户名已存在，请换一个！', {icon: 5, time: 1500});
								$('#submit').prop('disabled', true);
								$('#username').focus();
							} else if($("#username").val().length>6)
									{ layer.msg('不能超过6个字符', {icon: 5, time: 1500}); 
									$('#username').focus();
									}
							else {
								layer.msg('用户名可用！', {icon: 1, time: 1500});
								$('#submit').prop('disabled', false);
								
							}
						}
					}
				}
		     $(function(){
		         /*点击改变按钮状态，已经简略掉ajax发送短信验证的代码*/
		         $('#getting').click(function(){
		        	 layer.msg('验证码已经发送到你的手机，注意查收！', {icon: 1, time: 1500});
		             var btn = $(this);
		             var count = 60;
		             var resend = setInterval(function(){
		                 count--;
		                 if (count > 0){
		                     btn.val(count+"秒后可重新获取");
		                     $.cookie("captcha", count, {path: '/', expires: (1/86400)*count});
		                 }else {
		                     clearInterval(resend);
		                     btn.val("获取验证码").removeAttr('disabled style');
		                 }
		             }, 1000);
		             btn.attr('disabled',true).css('cursor','not-allowed');
		         });
		     });
 		</script>
	</body>
</html>